﻿using Microsoft.EntityFrameworkCore.Migrations;

namespace NFine.Data.Migrations
{
    public partial class Add_WxUser_Entity : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_WxUsers_sys_tenant_TenantId",
                table: "WxUsers");

            migrationBuilder.DropPrimaryKey(
                name: "PK_WxUsers",
                table: "WxUsers");

            migrationBuilder.RenameTable(
                name: "WxUsers",
                newName: "wx_user");

            migrationBuilder.RenameIndex(
                name: "IX_WxUsers_TenantId",
                table: "wx_user",
                newName: "IX_wx_user_TenantId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_wx_user",
                table: "wx_user",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_wx_user_sys_tenant_TenantId",
                table: "wx_user",
                column: "TenantId",
                principalTable: "sys_tenant",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_wx_user_sys_tenant_TenantId",
                table: "wx_user");

            migrationBuilder.DropPrimaryKey(
                name: "PK_wx_user",
                table: "wx_user");

            migrationBuilder.RenameTable(
                name: "wx_user",
                newName: "WxUsers");

            migrationBuilder.RenameIndex(
                name: "IX_wx_user_TenantId",
                table: "WxUsers",
                newName: "IX_WxUsers_TenantId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_WxUsers",
                table: "WxUsers",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_WxUsers_sys_tenant_TenantId",
                table: "WxUsers",
                column: "TenantId",
                principalTable: "sys_tenant",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
